package internationalenergytradingplatform.dao;

import com.github.pagehelper.Page;
import internationalenergytradingplatform.dto.PackagePageQueryDTO;
import internationalenergytradingplatform.pojo.Commodity;
import internationalenergytradingplatform.pojo.Package;
import org.apache.ibatis.annotations.*;

@Mapper
public interface PackageMapper {
    Page<Package> PackagePageQuery(PackagePageQueryDTO packagePageQueryDTO);

    /**
     *
     * @author yingfeng
     * @date 2024/3/13 14:26
     上架/下架套餐
     */

    @Update("update package_tb set sales_status = #{status} where id = #{id};")
    void listingProducts(@Param("id") Integer id, @Param("status") Integer status);

    @Delete("delete from package_tb where id=#{id}")
    void deleteCommodity(Integer id);

    @Update("update package_tb set name = #{name} , " +
            " supplier_accountr = #{supplierAccountr} , " +
            "price = #{price} , inventory = #{inventory} , " +
            "inventory_unit = #{inventoryUnit} , img = #{img} , " +
            "price_unit = #{priceUnit} where id = #{id};")
    void modifyPackage(Package package1);

    /**
     * 根据ID查询商品
     */
    @Select("select * from package_tb where id = #{id}")
    public Package getPackageById(@Param("id") Integer id);

    @Insert("insert into package_tb values(null, #{name}, #{supplierAccountr}, #{img}," +
            " #{price}, #{priceUnit}, #{salesStatus}, #{inventory}, #{inventoryUnit})" )
    void addPackage(Package package1);
}
